
$(function(){
    /*页面加载判断投票按钮状态--start*/
   var btn_img_id = $(".gtvate_btn img").attr("id");
    //获取主页医生的id
    var detail_id = $("#id_hidden").val();
    //所有医生的用户id--字符类型
    var much_id = $("input[name='vote_id']").val();
    //将所有用户id -装换为数组类型
    var arr_ids = much_id.split("-");
   //投票记录表中医生id的数据
    var re_bd_id = $("input[name='vote_re_id']").val().split("-");

    for(var s in arr_ids){
        for(var i in re_bd_id){
            var  a = parseInt(re_bd_id[i]) ;
            var s_id =parseInt(arr_ids[s])
            if(s_id==a){
                if(btn_img_id == 'I_vote' && a==detail_id ){
                    $("#now_vote_show").css('color','#ff6666');
                    $(".gtvate_btn img").attr("src","<?= G_SITE_CDN ?>/business/style/vote/style/gtvoteH.png");
                }
                $("#img" + a).attr("src", "<?= G_SITE_CDN ?>/business/style/vote/style/voteH.png");
            }
        }
    }
    /*页面加载判断投票按钮状态--end*/
   $(".vote_content_container_more img").click(function(){
        src=$(".vote_content_container_more img").attr("src");
        if(src=="<?= G_SITE_CDN ?>/business/style/vote/style/vote_arrow1.png"){
            $(".vote_content_container_more img").attr("src","<?= G_SITE_CDN ?>/business/style/vote/style/vote_arrow2.png");
            $(".vote_content_container").css("height","auto")
        }else{
            $(".vote_content_container_more img").attr("src","<?= G_SITE_CDN ?>/business/style/vote/style/vote_arrow1.png");
            $(".vote_content_container").css("height","130px")
        }
    })


    $(".gtvate_btn").click(function(){
        var id = $("#id_hidden").val();
        var type = 'big';
        vote(id,type);
    })

    $(".grid-item-agree").click(function(){
        var id = $(this).children("input").val();
        var type = 'small';
        vote(id,type);
    })

    //我要投票加1效果
    function add_one() {
        $.tipsBox({
            obj: $("#btn"),
            str: "+1",
            callback: function () {
            }
        });
    }


})
function vote(id,type) {
    var url = $("#url").val();
    $.post(url, {'id': id}, function (data) {
        if (data == 'no') {
            common.showMsgBox('您今天已经给他投过票了！');
        } else if(data =='beyond'){
            common.showMsgBox('您最多只能投票10次');
        }else if(data == 'no_id'){
            common.showMsgBox('投票不成功！');
        }else {

            if (type == 'big') {
                $("#now_vote_show").css('color','#ff6666');
                $(".gtvate_btn img").attr("src", "<?= G_SITE_CDN ?>/business/style/vote/style/gtvoteH.png");
                $("#now_vote_num" + id).html(data);
                show();
             // add_one();

            } else {
                common.showMsgBox('感谢您的投票！');
                $("#img" + id).attr("src", "<?= G_SITE_CDN ?>/business/style/vote/style/voteH.png");
                $("#vote_num" + id).html(data);
            }

        }
    })
}

    //留言开始
    $(".vote_Submit").click(function () {
        var tel = $.trim($("input[name='tel']").val());
        if(tel.length==0){
            alert('请输入您的联系方式')
            return false;
        }
        $("#form11").submit();

    })
    $('input:radio[name="people"]').change(function(){
        if($(".parent")[0].checked==true){
            $(".vote_parent").addClass("vote_parentH");
            $(".vote_doctor").removeClass("vote_doctorH");
        }else{
            $(".vote_parent").removeClass("vote_parentH");
            $(".vote_doctor").addClass("vote_doctorH");
        }
    })
    $(".vote_parent").click(function(){
        $(".parent").click();
    })
    $(".vote_doctor").click(function(){
        $(".doctor").click();
    })

   function show(){
       $(".vote_leave_msg_bg").show();
       $(".vote_leave_msg").show();
   }
    function closevote(){
        $(".vote_leave_msg_bg").hide();
        $(".vote_leave_msg").hide();
    }
    //留言结束





